﻿<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../helpproject.xsl" ?>
<topic template="Default" lasteditedby="Geert" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd">
  <title translate="true">WCF services</title>
  <keywords>
    <keyword translate="true">Data</keyword>
    <keyword translate="true">Data handling</keyword>
    <keyword translate="true">WCF</keyword>
  </keywords>
  <body>
    <header>
      <para styleclass="Heading1"><text styleclass="Heading1" translate="true">WCF services</text></para>
    </header>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">Starting with version 2.3, both the windows and Silverlight (Silverlight and WP7) libraries use the </text><link displaytype="text" defaultstyle="true" type="weblink" href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer.aspx" target="_blank" styleclass="Normal" translate="true">DataContractSerializer</link><text styleclass="Normal" translate="true"> to (de)serialize xml by default for the </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_Data_ModelBase" styleclass="Normal" translate="true">ModelBase</link><text styleclass="Normal" translate="true">. The xml serialization technique supports complex nested object graphs. This means that classes deriving from </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_Data_ModelBase" styleclass="Normal" translate="true">ModelBase</link><text styleclass="Normal" translate="true"> can be used to transfer data using WCF services.</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">There is no need to decorated the classes with </text><text styleclass="Normal" style="font-style:italic;" translate="true">DataMember</text><text styleclass="Normal" style="font-style:normal;" translate="true"> or </text><text styleclass="Normal" style="font-style:italic;" translate="true">DataContract</text><text styleclass="Normal" style="font-style:normal;" translate="true"> attributes with one single exception: when a class contains properties that are defined using a base class, the descending (or inherited) classes must be known. Catel could, in theory, reflect the whole </text><text styleclass="Normal" style="font-style:italic;" translate="true">AppDomain</text><text styleclass="Normal" style="font-style:normal;" translate="true"> to gather these classes, but that would be a major hit on performance. Therefore the inherited classes must be defined manually using the </text><text styleclass="Normal" style="font-style:italic;" translate="true">KnownType</text><text styleclass="Normal" style="font-style:normal;" translate="true"> attribute.</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">[Serializable, KnownType(Manager), KnownType(Employee)]</text><br/><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true">public</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">&#32;</text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true">class</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true"> Job : ModelBase&lt;Job&gt;</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">{</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true"> &#160; &#160;</text><text styleclass="Code Example" style="font-weight:normal; font-style:italic; color:#800000;" translate="true">// abstract Person class which can be Manager or Employee</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true"> &#160; &#160;</text><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true">public</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true"> Person Person { get; set; }</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">} </text></para>
    <para styleclass="Normal"><text styleclass="Normal" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">When adding the service reference, make sure to check the &quot;Reuse types in all referenced assemblies&quot; like shown in the image below:</text></para>
    <para styleclass="Normal"><image src="wcf_servicereference.png" scale="80.00%" width="544" height="500" styleclass="Image Caption"></image></para>
  </body>
</topic>
